package edu.hrbeu.crc.common.utils;

import com.baomidou.mybatisplus.core.toolkit.AES;
import edu.hrbeu.crc.properties.AesProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class AesUtil {
    @Autowired
    private final AesProperties aesProperties;

    @Autowired
    public AesUtil(AesProperties aesProperties) {
        this.aesProperties = aesProperties;
    }

    public String encrypt(String data) {
        // 使用 aesConfig.getKey() 进行加密
        return AES.encrypt(data, aesProperties.getKey());
    }

    public String decrypt(String encryptedData) {
        // 使用 aesConfig.getKey() 进行解密
        return AES.decrypt(encryptedData, aesProperties.getKey());
    }
}
